<!DOCTYPE HTML>
<html>
<head>
    <meta charset="utf-8">
    <meta name="renderer" content="webkit|ie-comp|ie-stand">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no"/>
    <link rel="Bookmark" href="imgs/bai.ico"/>
    <link rel="Shortcut Icon" href="imgs/bai.ico"/>
    <title>稍等…</title>
    <style type="text/css">
        body { margin: 0; padding: 0; background: #eee; }
        #body { max-width: 500px; min-width: 300px; background: #fff; text-align: center; }
        #load { margin: 0 auto; padding-top: 20px; width: 100px; height: 100px; background: #ccc; border-radius: 5px; color: #fff; display: none; }
        img { width: 60px; height: 60px; }
    </style>
</head>
<body>
    <div id="body">
        <div style="height: 20%;"></div>
        <div id="load">
            <img src="imgs/load.gif"/><br/>
            稍等…
        </div>
    </div>
</body>
</html>


<script type="text/javascript" src="js/jquery-1.7.2.min.js"></script>
<script type="text/javascript" src="js/view.js"></script>
<script type="text/javascript" src="js/index.js"></script>
<script type="text/javascript">
    var cw = document.documentElement.clientWidth;
    var ch = document.documentElement.clientHeight;
    var userInfo = getUserInfo();
    code = getParamByUrl('code');
    var h5code = getParamByUrl('h5code');
    if (!h5code) {
        var ts = new Date().getTime();
        ts = ts + '' + randInt(100, 999);
        window.location.href = '/h5/?code=' + code + '&h5code=' + ts;
    }
    var loadDiv = $('#load'), ndDiv = $('#nodata');
    (function () {
        $('#body').css('width', cw).css('height', ch);
        if (code == '') {
            ndDiv.show(); loadDiv.hide();
        } else {
            ndDiv.hide(); loadDiv.show();
        }
        toH5code();
    })();
    //获取登录信息
    function toH5code(){
        var formData = {
            code: code, h5code: h5code,
        };
        $.ajax({
            type: apis.toh5code.method,
            url: apis.toh5code.url,
            data: formData,
            success: function (res) {
                console.log(res);
                var p = '';
                if (res.code < 0) {
                    msgPop({msg: res.msg});
                    return
                }
                var code_used = res.data.code_used;
                var view_name = '', errMsg = '';
                if (code_used == 1) { //空码
                    view_name = routes.indexno;
                    errMsg = '空码';
                } else if (code_used == 2) { //已使用
                    view_name = routes.tmpOne;
                } else { //无效码
                    view_name = routes.indexno;
                    errMsg = '无效码';
                }
                p = '?code=' + code + '&h5code=' + h5code + '&errMsg=' + escape(errMsg);
                window.location.href = view_name + p;
            },
            error: function () {
                console.log('error');
            }
        });
    }
</script>